//There are configurable Macros: 
`ifndef CHUNJUN_MBUS_DATA_W
  `define CHUNJUN_MBUS_DATA_W 64
`endif
`ifndef CHUNJUN_SUPPORT_F_EXT
  `define CHUNJUN_SUPPORT_F_EXT
`endif
`ifdef CHUNJUN_SUPPORT_F_EXT
`ifndef CHUNJUN_SUPPORT_D_EXT
  //`define CHUNJUN_SUPPORT_D_EXT
  `endif

`endif
`ifndef CHUNJUN_SUPPORT_V_EXT
  //`define CHUNJUN_SUPPORT_V_EXT
`endif
`ifndef CHUNJUN_SUPPORT_WHWS_EXT
  `define CHUNJUN_SUPPORT_WHWS_EXT
`endif
`ifndef CHUNJUN_SUPPORT_TCM
  `define CHUNJUN_SUPPORT_TCM
`endif
`ifdef CHUNJUN_SUPPORT_TCM
`ifndef CHUNJUN_SUPPORT_3TCM
  `define CHUNJUN_SUPPORT_3TCM
  `endif
 
`endif
`ifndef CHUNJUN_SUPPORT_ICACHE
  `define CHUNJUN_SUPPORT_ICACHE
`endif
`ifndef CHUNJUN_SUPPORT_DCACHE
  `define CHUNJUN_SUPPORT_DCACHE
`endif
`ifndef CHUNJUN_SUPPORT_MEM_ECC
// `define CHUNJUN_SUPPORT_MEM_ECC 
`endif
`ifndef CHUNJUN_SUPPORT_DEBUG
  `define CHUNJUN_SUPPORT_DEBUG
`endif
`ifdef CHUNJUN_SUPPORT_DEBUG
`ifndef CHUNJUN_SUPPORT_DBG_IF_JTAG
  `define CHUNJUN_SUPPORT_DBG_IF_JTAG
  `endif

`endif
`ifdef CHUNJUN_SUPPORT_DEBUG
`ifndef CHUNJUN_SUPPORT_DBG_IF_CJTAG
// `define CHUNJUN_SUPPORT_DBG_IF_CJTAG 
  `endif

`endif
`ifndef CHUNJUN_SUPPORT_APLIC
  `define CHUNJUN_SUPPORT_APLIC
`endif
`ifndef CHUNJUN_SUPPORT_L2TCM
  `define CHUNJUN_SUPPORT_L2TCM
`endif
`ifndef CHUNJUN_CORE1_EN
  `define CHUNJUN_CORE1_EN
`endif
`ifndef CHUNJUN_CORE2_EN
  `define CHUNJUN_CORE2_EN
`endif
`ifndef CHUNJUN_CORE3_EN
  `define CHUNJUN_CORE3_EN
`endif
`ifndef CHUNJUN_PMP_ENTRY_N
  `define CHUNJUN_PMP_ENTRY_N 32
`endif
`ifndef CHUNJUN_PMA_ENTRY_N
  `define CHUNJUN_PMA_ENTRY_N 6
`endif
`ifndef CHUNJUN_ITCM_SIZE
  `define CHUNJUN_ITCM_SIZE 64
`endif
`ifndef CHUNJUN_DTCM0_SIZE
  `define CHUNJUN_DTCM0_SIZE 64
`endif
`ifndef CHUNJUN_DTCM1_SIZE
  `define CHUNJUN_DTCM1_SIZE 64
`endif
`ifndef CHUNJUN_ICACHE_SIZE
  `define CHUNJUN_ICACHE_SIZE 32
`endif
`ifndef CHUNJUN_DCACHE_SIZE
  `define CHUNJUN_DCACHE_SIZE 32
`endif
`ifndef CHUNJUN_LOC_INT_N
  `define CHUNJUN_LOC_INT_N 64
`endif
`ifndef CHUNJUN_GLOBAL_INT_N
  `define CHUNJUN_GLOBAL_INT_N 64
`endif
`ifndef CHUNJUN_BRPT_TRIG_N
  `define CHUNJUN_BRPT_TRIG_N 4
`endif
`ifndef CHUNJUN_VTCM_SIZE
  `define CHUNJUN_VTCM_SIZE 64
`endif
`ifndef CHUNJUN_VLEN_W
  `define CHUNJUN_VLEN_W 128
`endif
`ifndef CHUNJUN_DLEN_W
  `define CHUNJUN_DLEN_W 64
`endif
`ifndef CHUNJUN_CORE_N
  `define CHUNJUN_CORE_N 4
`endif
`ifndef CHUNJUN_L2TCM_SIZE
  `define CHUNJUN_L2TCM_SIZE 256
`endif
//There are macros associated with configurable macros : 
 // Warning!!! Any attempts to modify the marcos definition below is UNEXCEPTABLE 
 // Please contact WingSemi Tech AE for further Support.
`ifdef CHUNJUN_SUPPORT_V_EXT
  `define CHUNJUN_SUPPORT_ZVE32X_EXT
`endif
`ifdef CHUNJUN_SUPPORT_TCM
  `define CHUNJUN_SUPPORT_A_EXT
`endif
`ifdef CHUNJUN_SUPPORT_DEBUG
  `define CHUNJUN_SUPPORT_NTRACE
`endif
`ifdef CHUNJUN_SUPPORT_TCM
  `define CHUNJUN_SUPPORT_ITCM
`endif
`ifdef CHUNJUN_SUPPORT_TCM
  `define CHUNJUN_SUPPORT_DTCM0
`endif
`ifdef CHUNJUN_SUPPORT_3TCM
  `define CHUNJUN_SUPPORT_DTCM1
`endif
`ifdef CHUNJUN_SUPPORT_V_EXT
  `define CHUNJUN_SUPPORT_VTCM
`endif
`ifndef CHUNJUN_VTCM_BANK_N
  `define CHUNJUN_VTCM_BANK_N (`CHUNJUN_DLEN_W/32)
`endif
`ifndef CHUNJUN_VTCM_RAM_ADDR_W
  `define CHUNJUN_VTCM_RAM_ADDR_W $clog2(`CHUNJUN_VTCM_SIZE*256/`CHUNJUN_VTCM_BANK_N)
`endif
  `ifdef CHUNJUN_SUPPORT_MEM_ECC
    `define CHUNJUN_VTCM_RAM_DATA_W 39
  `else
    `define CHUNJUN_VTCM_RAM_DATA_W 32
  `endif 
`ifndef CHUNJUN_VPU_VLQ_ENTRY_N
  `define CHUNJUN_VPU_VLQ_ENTRY_N (`CHUNJUN_DLEN_W/32)*4
`endif
`ifndef CHUNJUN_VLQID_W
    `define CHUNJUN_VLQID_W $clog2(`CHUNJUN_VPU_VLQ_ENTRY_N) 
`endif
`ifndef CHUNJUN_ITCM_RAM_ADDR_W
  `define CHUNJUN_ITCM_RAM_ADDR_W $clog2(`CHUNJUN_ITCM_SIZE * 128)
`endif
`ifndef CHUNJUN_DTCM0_RAM_ADDR_W
  `define CHUNJUN_DTCM0_RAM_ADDR_W $clog2(`CHUNJUN_DTCM0_SIZE * 128)
`endif
`ifndef CHUNJUN_DTCM1_RAM_ADDR_W
  `define CHUNJUN_DTCM1_RAM_ADDR_W $clog2(`CHUNJUN_DTCM1_SIZE * 128)
`endif
  `ifdef CHUNJUN_SUPPORT_MEM_ECC
    `define CHUNJUN_ITCM_RAM_DATA_W 72
  `else
    `define CHUNJUN_ITCM_RAM_DATA_W 64
  `endif
  `ifdef CHUNJUN_SUPPORT_MEM_ECC
    `define CHUNJUN_DTCM_RAM_DATA_W 39
  `else
    `define CHUNJUN_DTCM_RAM_DATA_W 32
  `endif
  `ifdef CHUNJUN_SUPPORT_MEM_ECC
    `define CHUNJUN_ITCM_RAM_WSTRB_W 9
  `else
    `define CHUNJUN_ITCM_RAM_WSTRB_W 8
  `endif
  `ifdef CHUNJUN_SUPPORT_MEM_ECC
    `define CHUNJUN_DTCM_RAM_WSTRB_W 5
  `else
    `define CHUNJUN_DTCM_RAM_WSTRB_W 4
  `endif
`ifndef CHUNJUN_L2TCM_RAM_ADDR_W
  `define CHUNJUN_L2TCM_RAM_ADDR_W $clog2(`CHUNJUN_L2TCM_SIZE * 128 / 8)
`endif
  `ifdef CHUNJUN_SUPPORT_MEM_ECC
    `define CHUNJUN_L2TCM_RAM_DATA_W 72
  `else
    `define CHUNJUN_L2TCM_RAM_DATA_W 64
  `endif
`ifndef CHUNJUN_IC_SET_N
  `define CHUNJUN_IC_SET_N (`CHUNJUN_ICACHE_SIZE * 32 / 2)
`endif
`ifndef CHUNJUN_IC_SETIDX_W
  `define CHUNJUN_IC_SETIDX_W $clog2(`CHUNJUN_IC_SET_N)
`endif
`ifndef CHUNJUN_IC_TAG_W
  `define CHUNJUN_IC_TAG_W (27 - `CHUNJUN_IC_SETIDX_W)
`endif
`ifndef CHUNJUN_IC_TAG_RAM_DATA_W
  `ifdef CHUNJUN_SUPPORT_MEM_ECC
    `define CHUNJUN_IC_TAG_RAM_DATA_W (8 + `CHUNJUN_IC_TAG_W)
  `else
    `define CHUNJUN_IC_TAG_RAM_DATA_W (1 + `CHUNJUN_IC_TAG_W)
  `endif
 
`endif
  `ifdef CHUNJUN_SUPPORT_MEM_ECC
    `define CHUNJUN_IC_DATA_RAM_DATA_W 72
  `else
    `define CHUNJUN_IC_DATA_RAM_DATA_W 64
  `endif
`ifndef CHUNJUN_IC_DATA_RAM_DEPTH_N
  `define CHUNJUN_IC_DATA_RAM_DEPTH_N (`CHUNJUN_IC_SET_N * 4)
`endif
`ifndef CHUNJUN_IC_DATA_RAM_ADDR_W
  `define CHUNJUN_IC_DATA_RAM_ADDR_W $clog2(`CHUNJUN_IC_DATA_RAM_DEPTH_N)
`endif
`ifndef CHUNJUN_DC_SET_N
  `define CHUNJUN_DC_SET_N (`CHUNJUN_DCACHE_SIZE * 32 / 4)
`endif
`ifndef CHUNJUN_DC_SETIDX_W
  `define CHUNJUN_DC_SETIDX_W $clog2(`CHUNJUN_DC_SET_N)
`endif
`ifndef CHUNJUN_DC_TAG_W
  `define CHUNJUN_DC_TAG_W (27 - `CHUNJUN_DC_SETIDX_W)
`endif
`ifndef CHUNJUN_DC_TAG_RAM_DATA_W
  `ifdef CHUNJUN_SUPPORT_MEM_ECC
    `define CHUNJUN_DC_TAG_RAM_DATA_W (9 + `CHUNJUN_DC_TAG_W)
  `else
    `define CHUNJUN_DC_TAG_RAM_DATA_W (2 + `CHUNJUN_DC_TAG_W)
  `endif
 
`endif
  `ifdef CHUNJUN_SUPPORT_MEM_ECC
    `define CHUNJUN_DC_DATA_RAM_DATA_W 39
  `else
    `define CHUNJUN_DC_DATA_RAM_DATA_W 32
  `endif
`ifndef CHUNJUN_DC_DATA_RAM_DEPTH_N
  `define CHUNJUN_DC_DATA_RAM_DEPTH_N (`CHUNJUN_DC_SET_N * 4)
`endif
`ifndef CHUNJUN_DC_DATA_RAM_ADDR_W
  `define CHUNJUN_DC_DATA_RAM_ADDR_W $clog2(`CHUNJUN_DC_DATA_RAM_DEPTH_N)
`endif
`ifndef CHUNJUN_LOC_INT_ID_W
  `define CHUNJUN_LOC_INT_ID_W $clog2(`CHUNJUN_LOC_INT_N+32)
`endif
`ifndef CHUNJUN_FBUS_DATA_W
  `define CHUNJUN_FBUS_DATA_W `CHUNJUN_MBUS_DATA_W
`endif
`ifndef CHUNJUN_TRIG_N
  `define CHUNJUN_TRIG_N (`CHUNJUN_BRPT_TRIG_N + 1)
`endif
`ifndef CHUNJUN_TRIG_IDX_W
  `define CHUNJUN_TRIG_IDX_W (((($clog2(`CHUNJUN_BRPT_TRIG_N) > $clog2(1)) ? $clog2(`CHUNJUN_BRPT_TRIG_N) : $clog2(1)) > 2 ? (($clog2(`CHUNJUN_BRPT_TRIG_N) > $clog2(1)) ? $clog2(`CHUNJUN_BRPT_TRIG_N) : $clog2(1)) : 2) + 2)
`endif
  `ifdef CHUNJUN_SUPPORT_D_EXT
    `define CHUNJUN_FP_DATA_W 64
  `elsif CHUNJUN_SUPPORT_F_EXT
    `define CHUNJUN_FP_DATA_W 32
  `endif
  `ifdef CHUNJUN_SUPPORT_F_EXT
    `define CHUNJUN_SUPPORT_FPU
  `endif
`ifndef CHUNJUN_SBUS_DATA_W
    `define CHUNJUN_SBUS_DATA_W `CHUNJUN_MBUS_DATA_W
`endif
  `ifdef CHUNJUN_SUPPORT_V_EXT
    `define CHUNJUN_PMP_LDST_N (2 + 2)
  `else
    `define CHUNJUN_PMP_LDST_N 2
  `endif
`ifndef CHUNJUN_VPU_VL_W
    `define CHUNJUN_VPU_VL_W $clog2(`CHUNJUN_VLEN_W+1) 
`endif 
`ifndef CHUNJUN_VPU_UVL_W
    `define CHUNJUN_VPU_UVL_W $clog2(`CHUNJUN_DLEN_W+1) 
`endif 
`ifndef CHUNJUN_VPU_UVLS_W
    `define CHUNJUN_VPU_UVLS_W $clog2(`CHUNJUN_DLEN_W/8+1) 
`endif 
`ifndef CHUNJUN_VPU_PATIAL_N
    `define CHUNJUN_VPU_PATIAL_N (`CHUNJUN_VLEN_W/`CHUNJUN_DLEN_W)
`endif 
`ifndef CHUNJUN_VPU_PATIAL_W
    `define CHUNJUN_VPU_PATIAL_W $clog2(`CHUNJUN_VLEN_W/`CHUNJUN_DLEN_W)
    `define CHUNJUN_VPU_PARTIAL_W  `CHUNJUN_VPU_PATIAL_W
`endif 
`ifndef CHUNJUN_VPU_DLEN_B_W
    `define CHUNJUN_VPU_DLEN_B_W $clog2(`CHUNJUN_DLEN_W/8) 
`endif 
`ifndef CHUNJUN_VPU_DLEN_B_N
    `define CHUNJUN_VPU_DLEN_B_N `CHUNJUN_DLEN_W/8 
`endif 
`ifndef CHUNJUN_VPU_V0_OFFSET_W
    `define CHUNJUN_VPU_V0_OFFSET_W $clog2(`CHUNJUN_DLEN_W/8) 
`endif 
`ifndef CHUNJUN_VPU_V0_RD_ADDR_W
    `define CHUNJUN_VPU_V0_RD_ADDR_W $clog2(`CHUNJUN_VLEN_W/(`CHUNJUN_DLEN_W/8))
`endif 
`ifndef CHUNJUN_VPU_V0_ADDR_W
    `define CHUNJUN_VPU_V0_ADDR_W `CHUNJUN_VPU_V0_RD_ADDR_W + `CHUNJUN_VPU_V0_OFFSET_W
`endif 
`ifndef CHUNJUN_VPU_V0_DATA_W
    `define CHUNJUN_VPU_V0_DATA_W (`CHUNJUN_DLEN_W/8)
`endif 
`ifndef CHUNJUN_VPU_BANK_DEPTH
    `define CHUNJUN_VPU_BANK_DEPTH ((`CHUNJUN_VLEN_W*32)/(`CHUNJUN_DLEN_W*8))
`endif 
`ifndef CHUNJUN_VPU_BANK_ADDR_W
    `define CHUNJUN_VPU_BANK_ADDR_W $clog2(`CHUNJUN_VPU_BANK_DEPTH)
`endif 
`ifndef CHUNJUN_VPU_VLQ_N
    `define CHUNJUN_VPU_VLQ_N `CHUNJUN_VPU_VLQ_ENTRY_N
    `define CHUNJUN_CORE_VLSQ_ENTRY_N `CHUNJUN_VPU_VLQ_ENTRY_N
`endif
`ifndef CHUNJUN_VPU_VLEN_W
    `define CHUNJUN_VPU_VLEN_W `CHUNJUN_VLEN_W
`endif
`ifndef CHUNJUN_VPU_DLEN_W
    `define CHUNJUN_VPU_DLEN_W `CHUNJUN_DLEN_W
`endif
`ifndef CHUNJUN_VPU_VLMAX_BW
    `define CHUNJUN_VPU_VLMAX_BW $clog2(`CHUNJUN_VPU_VLEN_W+1)
`endif
`ifndef WING_BRPT_TRIG_N
    `define WING_BRPT_TRIG_N `CHUNJUN_BRPT_TRIG_N
`endif
`ifndef WING_BRPT_TRIG_W
    `define WING_BRPT_TRIG_W ($clog2(`CHUNJUN_BRPT_TRIG_N))
`endif
`ifdef CHUNJUN_SUPPORT_V_EXT
  `define WING_TM_SUPPORT_V_EXT
`endif
`ifdef CHUNJUN_SUPPORT_WHWS_EXT
    `define WING_SUPPORT_WHWS_EXT
`endif 
`ifndef WING_TM_NUM
    `define WING_TM_NUM      (`WING_BRPT_TRIG_N + 0 + 0 + 0 + 0) 
`endif 
`ifndef WING_TM_TRIG_NUM_W
    `define WING_TM_TRIG_NUM_W     ($clog2(`WING_TM_NUM))
`endif 
`ifndef WING_TMR_MAX_SELECT
  `define WING_TMR_MAX_SELECT         (`WING_TM_NUM - 1)
`endif 
`ifdef CHUNJUN_PMP_ENTRY_N
  `ifndef PMP_ENTRY_N
    `define PMP_ENTRY_N `CHUNJUN_PMP_ENTRY_N
  `endif

`endif
`ifdef CHUNJUN_PMA_ENTRY_N
  `ifndef PMA_ENTRY_N
    `define PMA_ENTRY_N `CHUNJUN_PMA_ENTRY_N
  `endif

`endif
`ifndef CHUNJUN_CORE1_EN
     `define WING_NTRACE_SUPPORT_SINGLE_HART
`endif
`ifdef CHUNJUN_CORE1_EN
       `define WING_NTRACE_CORE1_EN  1
`endif 
`ifdef CHUNJUN_CORE2_EN
       `define WING_NTRACE_CORE2_EN  1
`endif 
`ifdef CHUNJUN_CORE3_EN
       `define WING_NTRACE_CORE3_EN  1
`endif 
`define WING_NTRACE_CORE_N `CHUNJUN_CORE_N
`ifndef CHUNJUN_MMR_ID_W
  `define CHUNJUN_MMR_ID_W ((8 + 2 + 3) + $clog2(2 * `CHUNJUN_CORE_N + 1) )
`endif
`ifdef CHUNJUN_SUPPORT_APLIC
  `define CHUNJUN_APLIC_INT_DOMAIN_N  1
`endif 
`define CHUNJUN_DM_HART_N `CHUNJUN_CORE_N
`define CHUNJUN_DM_HART_N_W $clog2(`CHUNJUN_DM_HART_N)
`ifndef CHUNJUN_CORE1_EN
      `define CHUNJUN_SUPPORT_SINGLE_HART
`endif
`ifdef CHUNJUN_SUPPORT_F_EXT
    `ifdef CHUNJUN_SUPPORT_V_EXT
        `define ISU_SUPPORT_F_V_EXT
    `else
        `define ISU_SUPPORT_F_EXT
    `endif

`endif
`ifdef CHUNJUN_SUPPORT_V_EXT
    `ifndef CHUNJUN_SUPPORT_F_EXT
        `define ISU_SUPPORT_V_EXT
    `endif
 
`endif
`ifndef CHUNJUN_SUPPORT_F_EXT
    `ifndef CHUNJUN_SUPPORT_V_EXT
        `define ISU_DONT_SUPPORT_F_V_EXT
    `endif
 
`endif
  `ifdef CHUNJUN_SUPPORT_DBG_IF_CJTAG
    `define CHUNJUN_CHUNJUN_TAP_IDCODE         32'h1DA01EF7
  `else  
      `define CHUNJUN_CHUNJUN_TAP_IDCODE         32'h1DA00EF7
  `endif 
`ifndef WING_CLIC_LOC_INT_N
  `define WING_CLIC_LOC_INT_N  `CHUNJUN_LOC_INT_N
`endif 
`ifndef WING_CLIC_LOC_INT_ID_W
  `define WING_CLIC_LOC_INT_ID_W   `CHUNJUN_LOC_INT_ID_W
`endif 
